package com.hghivln.blog.controller;

import com.hghivln.blog.common.lang.Result;
import com.hghivln.blog.common.upload.UploadService;
import com.hghivln.blog.pojo.vo.UploadVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("doUpload")
    public Object doUpload(MultipartFile file){
        UploadVo uploadVo = uploadService.uploadImage(file);
        return new Result<>(uploadVo);
    }
}
